#conding = utf-8
from page.register_page import RegisterPage


class RegisterHandle(object):
    def __init__(self,driver):
        self.register_p = RegisterPage(driver)

    #输入手机号
    def send_phone(self,phone):
        self.register_p.get_phone_element().send_keys(phone)

    #输入验证码
    def send_code(self,code):
        self.register_p.get_code_element().send_keys(code)

    #输入手机验证码
    def send_phone_code(self,phone_code):
        self.register_p.get_phone_code_element().send_keys(phone_code)

    #输入密码
    def send_password(self,password):
        self.register_p.get_password_element().send_keys(password)
        
    #确认密码
    def send_confirm_password(self,confirm_password):
        self.register_p.get_confirm_password_element().send_keys(confirm_password)

    #注册按钮
    def send_register_button(self,register_button):
        self.register_p.get_register_button_element().click()

    #获取文字信息-错误信息   #找不到元素信息返回none
    def get_register_error(self,info,user_info):
        try:
            if info == 'phone_error':
                text = self.register_p.get_phone_error().text
            elif info == 'code_error':
                text = self.register_p.get_code_error_element().text
            elif info == 'phone_code_error':
                text = self.register_p.get_phone_code_error_element().text
            elif info == 'password_error':
                text = self.register_p.get_password_error_element().text
            elif info == 'confirm_password_error':
                text = self.register_p.get_confirm_password_error_element().text
        except:
            return text
        return text
    
    #获取点击注册按钮的文字
    def get_register_button_text(self):
        self.register_p.get_register_button_element().text

        

    
    
    